<template>
	<view class="installDetails">
		<f-loading ref="loading" />
		<f-uToast ref="uToast" />
		<f-compressImgs ref="compressImgs" />
		<f-navbar :title="titleList.title" :iconLeft="titleList.iconLeft" />
		<u-popup :show="unbindParmas.popupState" mode="right" width="70%" :closeOnClickOverlay="true" @close="closePopup">
			<view
				class="ff-width-110 ff-margin-top-130 ff-padding-bottom-15 ff-padding-top-15 ff-border-top ff-border-bottom ff-text-center"
				@click="unbindConfirm">
				解绑
			</view>
		</u-popup>
		<view class="installDetails-service ff-padding-13 ff-bg-fff ff-border-radius-10 ff-line-height-1-3">
			<view class="ff-flex-between">
				<view class="ff-font-16 ff-font-weight-600 ff-margin-bottom-20">业务信息</view>
				<view><u-icon @click="unbindingClick" name="more-dot-fill" color="#333333" size="21"></u-icon></view>
			</view>
			<view class="ff-flex ff-margin-bottom-15">
				<view class="ff-color-666 ff-width-28">业务平台</view>
				<view class="ff-flex-1">{{ details.installDetails.systemName }}</view>
			</view>
			<view class="ff-flex">
				<view class="ff-color-666  ff-width-28">安装单位</view>
				<view class="ff-flex-1">{{ details.installDetails.installOrgName }}</view>
			</view>
			<view class="ff-flex  ff-margin-top-15"
				v-for="(item, index) of details.installDetails.thirdPartySystemInstallConfig" :key="index">
				<view class="ff-color-666 ff-width-28">{{ item.fieldName }}</view>
				<view class="ff-flex-1">{{ item.fieldValueStr || '/' }}</view>
			</view>
		</view>
		<view class="ff-margin-top-10">
			<u-tabs :current="tabsBox.tabsCurrent" :list="tabsBox.tabsList"
				:activeStyle="{ color: '#2954FD', 'font-weight': 600, 'font-size': '32rpx' }" lineColor="#2954FD"
				:scrollable="false" @click="tabsClick"></u-tabs>
			<view>
				<view v-if="tabsBox.tabsCurrent == 0">
					<view class="ff-margin-top-15 ff-line-height-1-2">
						<view class="ff-bg-fff ff-padding-13 ff-border-radius-10">
							<view class="ff-color-666 ff-margin-bottom-15">产品信息</view>
							<view class="ff-bg-F5F8FF ff-margin-bottom-10 ff-padding-12 ff-border-radius-3 ff-font-14">
								<view class="ff-flex ff-margin-bottom-12">
									<view class="ff-color-999 ff-width-20">产品</view>
									<view>{{ details.installDetails.productName }}</view>
								</view>
								<view class="ff-flex ff-margin-bottom-12">
									<view class="ff-color-999 ff-width-20">分类</view>
									<view>{{ details.installDetails.classifyName }}</view>
								</view>
								<view class="ff-flex">
									<view class="ff-color-999 ff-width-20">供应商</view>
									<view>{{ details.installDetails.supplierName }}</view>
								</view>
							</view>
							<view v-if="details.installDetails.isTeleporter == 1">
								<view class="ff-flex ff-margin-top-20 ff-margin-bottom-15">
									<view class="ff-color-999 ff-width-23 ff-margin-right-15">终端编码</view>
									<view>{{ details.installDetails.deviceImei }}</view>
								</view>
								<view class="ff-flex ff-margin-bottom-15">
									<view class="ff-color-999 ff-width-23 ff-margin-right-15">主机品牌</view>
									<view>{{ details.installDetails.manufactorName }}</view>
								</view>
								<view class="ff-flex ff-margin-bottom-15">
									<view class="ff-color-999 ff-width-23 ff-margin-right-15">解析协议</view>
									<view>{{ details.installDetails.protocolName || '/' }}</view>
								</view>
							</view>
							<view class="ff-flex ff-margin-bottom-15">
								<view class="ff-color-999 ff-width-23 ff-margin-right-15">安装区域</view>
								<view>
									{{ details.installDetails.deptProvinceName + details.installDetails.deptCityName + details.installDetails.deptAreaName }}
								</view>
							</view>
							<view class="ff-flex ff-margin-bottom-15">
								<view class="ff-color-999 ff-width-23 ff-margin-right-15">街道/乡/镇</view>
								<view>{{ details.installDetails.deptStreetName || '/' }}</view>
							</view>
							<view class="ff-flex ff-margin-bottom-15">
								<view class="ff-color-999 ff-width-23 ff-margin-right-15">村居/社区</view>
								<view>{{ details.installDetails.deptVillageName || '/' }}</view>
							</view>
							<view class="ff-flex ff-margin-bottom-15">
								<view class="ff-color-999 ff-width-23 ff-margin-right-15">详细地址</view>
								<view class="ff-flex-1">{{ details.installDetails.address }}</view>
							</view>
							<view class="ff-flex ff-margin-bottom-15">
								<view class="ff-color-999 ff-width-23 ff-margin-right-15">安装位置</view>
								<view class="ff-flex-1">{{ details.installDetails.position }}</view>
							</view>
						</view>
					</view>
					<view class="ff-margin-top-15 ff-line-height-1-2">
						<view class="ff-bg-fff ff-padding-13 ff-border-radius-10">
							<view>
								<view class="ff-color-666 ff-margin-bottom-15">安装图片</view>
								<view class="imgsBox ff-flex-wrap" v-if="details.installDetails.installImg&&details.installDetails.installImg.length >0">
									<view class="imgsBox-img" v-for="(item, index) of details.installDetails.installImg"
										:key="index">
										<view class="ff-margin-bottom-10" @click="previewImgClick(item, 1)">
											<image class="imgDevice" :src="item" mode="" />
										</view>
									</view>
								</view>
								<view v-else class="imgsBox ff-flex-wrap">
									<view class="imgsBox-img">
										<image class="imgDevice"
											src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/noImg.png"
											mode="" />
									</view>
								</view>
							</view>
							<view class="ff-margin-top-15" v-if="details.installDetails.isTeleporter == 1">
								<view class="ff-color-666 ff-margin-bottom-15">火灾控制器(消防主机)图片</view>
								<view class="imgsBox ff-flex-wrap">
									<view class="imgsBox-img" v-for="(item, index) of details.installDetails.fireImg"
										:key="index">
										<view class="ff-margin-bottom-10" @click="previewImgClick(item, 2)">
											<image class="imgDevice" :src="item" mode="" />
										</view>
									</view>
									<view class="imgsBox-img" v-if="details.installDetails.fireImg.length < 1">
										<image class="imgDevice"
											src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/noImg.png"
											mode="" />
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="ff-margin-top-15 ff-bg-fff ff-border-radius-10 ff-padding-13 ff-line-height-1-2">
						<view class="ff-flex">
							<view class="ff-color-666 ff-margin-bottom-15 ff-width-20">安装人</view>
							<view>{{ details.installDetails.installUserName }}</view>
						</view>
						<view class="ff-flex">
							<view class="ff-color-666 ff-margin-bottom-15 ff-width-20">手机号</view>
							<view>{{ details.installDetails.installUserPhone }}</view>
						</view>
						<view class="ff-flex">
							<view class="ff-color-666 ff-width-20">备注</view>
							<view>{{ details.installDetails.installRemark || '/' }}</view>
						</view>
					</view>
				</view>
				<view v-if="tabsBox.tabsCurrent == 1">
					<view class="ff-margin-top-15 ff-bg-fff ff-padding-13 ff-border-radius-10">
						<view v-if="details.installDetails.isTeleporter == 1">
							<view class="ff-font-weight-600 ff-margin-bottom-10">上线状态</view>
							<view class="ff-color-666 ff-margin-bottom-13 ff-font-13">设备安装完成后，接入电源，等待蓝灯闪烁停止</view>
						</view>
						<view class="ff-bg-F5F8FF ff-padding-10 ff-font-14 ff-margin-bottom-15">
							<view class="ff-flex-between ff-align-items-one">
								<view>
									<view class="ff-align-items-one">
										<view class="ff-font-weight-600 ff-margin-right-10">状态</view>
										<view>
											<view v-if="details.installDetails.isOnline == 0" class="tips1 ff-font-13">未上线</view>
											<view v-if="details.installDetails.isOnline == 1" class="tips2 ff-font-13">已上线</view>
										</view>
									</view>
								</view>
								<view class="ff-align-items-one">
									<image class="renovate"
										src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/renovateIcon.png"
										mode=""></image>
									<view class="ff-color-blue" @click.stop="getOnline(details.installDetails.id)">刷新</view>
								</view>
							</view>
						</view>
						<view
							:class="{'ff-padding-bottom-15':details.installDetails.isTeleporter == 1, 'ff-border-bottom':details.installDetails.isTeleporter == 1}"
							class="ff-padding-top-15 ff-border-top ff-font-14 ff-line-height-1-3">
							<view class="ff-font-weight-600 ff-margin-bottom-10">输出数据</view>
							<view class="ff-color-666 ff-font-13" v-if="details.installDetails.isTeleporter == 1">
								请消控主机操作人员操作主机复位功能，操作完毕后，选择可以正确解析汉字的协议。</view>
							<view class="ff-flex-between ff-align-items-one ff-padding-top-20"
								v-if="details.installDetails.isTeleporter == 1">
								<view class="ff-relative">主机品牌</view>
								<view>
									<picker mode="selector" :value="brands.brandIndex" :range="brands.brandNameList"
										@change="confirmBrand">
										<view class="tabsAllBox-but-type">
											<view v-if="!brands.brandName" class="ff-align-items-one">
												<view class="ff-color-999">请选择</view>
												<u-icon name="arrow-right" color="#999999"></u-icon>
											</view>
											<view v-else class="ff-align-items-one">
												<view class="tabsAllBox-but-type-title">{{ brands.brandName }}</view>
												<u-icon name="arrow-right" color="#333"></u-icon>
											</view>
										</view>
									</picker>
								</view>
							</view>
						</view>
						<view :class="{'ff-padding-bottom-15':details.installDetails.isTeleporter == 1}" class="ff-relative">
							<view v-if="details.installDetails.isTeleporter == 1">
								<view class="ff-font-weight-600 ff-padding-top-15 ff-margin-bottom-13">解析协议</view>
								<view class="ff-color-666 ff-font-10">如输出内容乱码，请切换协议</view>
								<view class="ff-margin-top-15">
									<view
										class="agreeBox ff-flex-wrap ff-align-items-one ff-flex-between  ff-text-center ff-color-999">
										<view v-for="(item, index) of agrees.agreeList" :key="index"
											:class="{ agreeActive: agrees.agreeIndex == index }" @click="agreeClick(item, index)"
											class="agreeBox-title ff-bg-F5F8FF ff-font-14 ff-padding-10 ff-border-radius-3">
											{{ item.protocolName }}
										</view>
									</view>
								</view>
							</view>
							<view class="ff-padding-13 ff-bg-F5F8FF ff-border-radius-3 agreeInfo ff-line-height-1-3">
								{{ lastData.info || '暂无数据' }}
								<view class="ff-align-items-one lastDataIcon" @click.stop="getLastData">
									<image class="renovate"
										src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/renovateIcon.png"
										mode=""></image>
									<view class="ff-color-blue">刷新</view>
								</view>
							</view>
						</view>
						<view class="ff-padding-top-15 ff-border-top ff-padding-bottom-15">
							<view>
								<view class="ff-font-weight-600 ff-margin-bottom-10 ff-width-20 ident ff-relative">解析结果</view>
								<u-radio-group v-model="testDeviceParams.testResult" :placement="row">
									<u-radio :name="1" :customStyle="{ marginRight: '100rpx' }" label="调试成功"></u-radio>
									<u-radio :name="2" label="调试失败"></u-radio>
								</u-radio-group>
							</view>
							<view class="ff-margin-top-15 ff-padding-13 ff-bg-F5F8FF ff-border-radius-3"
								v-if="details.installDetails.isTeleporter == 1 && testDeviceParams.testResult == 2">
								<view class="ff-font-weight-600 ff-font-14 ff-margin-bottom-13">请选择失败原因</view>
								<u-radio-group v-model="testDeviceParams.testFailReason" placement="column"
									iconPlacement="right">
									<u-radio :name="1" :customStyle="{ marginBottom: '20rpx' }" label="有数据无法解析"></u-radio>
									<u-radio :name="2" label="无数据"></u-radio>
								</u-radio-group>
							</view>
						</view>
						<view class="ff-border-top ff-padding-top-15">
							<view class="addDevice-box-content-title ff-font-weight-600 ff-margin-bottom-15">安装图片</view>
							<view>
								<view class="imgsBox ff-flex-wrap">
									<view class="imgsBox-img" v-for="(item, index) of testDeviceParams.installImg" :key="index">
										<view class="ff-margin-bottom-10 ff-relative" @click="previewImgClick(item, 3)">
											<image class="imgDevice" :src="item" mode="" />
											<view @click.stop="deteleImgClick(index)" class="closeIcon"><u-icon name="close"
													color="#fff" size="12"></u-icon></view>
										</view>
									</view>
									<view class="imgsBox-img">
										<image class="imgDevice" @click="upateImgClick"
											src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/take-photos.png"
											mode="" />
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="tabsBut"><u-button type="primary" text="保存" @click.stop="installSubmit"></u-button></view>
				</view>
			</view>
		</view>
	</view>
</template>


<script setup>
	import { getCurrentInstance, onMounted, reactive, ref } from 'vue';
	import { onLoad, onPageScroll } from '@dcloudio/uni-app';
	import { useStore } from 'vuex';
	import config from '@/tools/config.js';
	const { state, commit, dispatch } = useStore();
	const { proxy } = getCurrentInstance();
	let uToast = ref(null);
	let loading = ref(null);

	// 上个页面传过来的数据
	let installId = ref(installId);
	onLoad(e => {
		// console.log('上个页面传过来的数据----', e);
		installId = e.installId;
		getInstallDetails(installId); // 获取安装详情
	});
	onMounted(() => {
		setTimeout(() => {
			getBrandList(); // 获取主机品牌的数据
		}, 100);
	});
	// 解绑
	let unbindParmas = reactive({ popupState: false })
	// 关闭解绑弹窗
	let closePopup = async () => {
		unbindParmas.popupState = false
	}
	let unbindingClick = () => {
		unbindParmas.popupState = true
	}
	let unbindConfirm = async () => {
		uni.showModal({
			title: '温馨提示',
			content: '是否解绑？',
			showCancel: true,
			confirmColor: '#2954FD',
			success: function (res) {
				if (res.confirm) {
					loading.value.openLoading('解绑中···'); // 打开loading
					proxy.$http.get({ url: `/install/unbindDevice/${details.id}` }).then(data => {
						// console.log('解绑后返回的数据------', data)
						loading.value.closeLoading(); // 关闭loading
						if (data.code == 200) {
							uToast.value.openuToastSuccess(data.msg);
							setTimeout(() => {
								proxy.$pageJump.reLaunch('/pages/views/install/index');
							}, 500)
						} else {
							uToast.value.openuToastError(data.msg);
						}
					})
				} else if (res.cancel) {}
			}
		});

	}

	// 导航栏相关
	let titleList = reactive({
		title: '安装详情',
		iconLeft: true
	});

	// tabs相关
	let tabsBox = reactive({
		tabsList: [{ name: '安装信息' }, { name: '调试信息' }],
		tabsCurrent: 0
	});
	let tabsClick = e => {
		// console.log('当前点击tabsIndex', e)
		tabsBox.tabsCurrent = e.index;
	};


	let details = reactive({
		installDetails: {},
		id: '', // 设备ID
		protocolId: '', // 协议ID
		manufactorId: '' // 主机品牌ID
	});
	// 获取安装详情
	let getInstallDetails = async id => {
		const data = await proxy.$http.get({ url: `/install/detail/${id}` });
		// console.log('获取安装详情---', data);
		if (data.code == 200) {
			details.installDetails = data.data;
			details.installDetails.thirdPartySystemInstallConfig = JSON.parse(details.installDetails
				.thirdPartySystemInstallConfig);
			brands.brandIndex = details.installDetails.manufactorId;
			brands.brandName = details.installDetails.manufactorName;
			details.id = details.installDetails.id; // 设备ID
			getLastData(); // 获取终端数据
			// 用传设备
			if (details.installDetails.isTeleporter == 1) {
				getAgreeList(details.installDetails.manufactorId); // 获取用传协议
				details.protocolId = details.installDetails.protocolId; // 协议ID
				details.manufactorId = details.installDetails.manufactorId; // 主机品牌ID
				handleupdProtocol(); // 改变用传设置
			}
			// 安装图片
			if (details.installDetails.installImg) {
				details.installDetails.installImg = details.installDetails.installImg.split(',');
			} else {
				details.installDetails.installImg = []
			}
			// 消防图片
			if (details.installDetails.fireImg) {
				details.installDetails.fireImg = details.installDetails.fireImg.split(',');
			} else {
				details.installDetails.fireImg = []
			}
			testDeviceParams.installImg = details.installDetails.installImg; // 调试信息的安装图片
			testDeviceParams.testResult = details.installDetails.testResult; // 调试信息的调试结果
			testDeviceParams.testFailReason = Number(details.installDetails.testFailReason); // 调试信息 失败的结果
		}
	};

	// 刷新---是否在线
	let getOnline = async id => {
		loading.value.openLoading('加载中···'); // 打开loading
		const data = await proxy.$http.get({ url: `/install/isOnline/${id}` });
		loading.value.closeLoading(); // 关闭loading
		if (data.code == 200) {
			if (data.data) {
				details.installDetails.isOnline = 1;
			}
		}
	};

	// 主机品牌相关----系列操作
	let brands = reactive({
		brandIndex: '',
		brandName: '',
		brandNameList: [],
		brandList: []
	});
	let getBrandList = async () => {
		loading.value.openLoading('加载中···'); // 打开loading
		const data = await proxy.$http.get({ url: '/teleporterManufactor/teleporterManufactor/getManufactorList' });
		loading.value.closeLoading(); // 关闭loading
		// console.log('主机品牌列表数据----', data.data);
		if (data.code == 200) {
			data.data.forEach(res => {
				brands.brandNameList.push(res.manufactorName);
				brands.brandList.push({
					label: res.manufactorName,
					id: res.id
				});
			});
		}
	};
	// 确定主机品牌弹窗
	let confirmBrand = e => {
		// console.log('确定主机品牌弹窗', e.detail);
		brands.brandIndex = e.detail.value;
		brands.brandName = brands.brandNameList[brands.brandIndex];
		getAgreeList(brands.brandList[brands.brandIndex].id); // 获取用传协议
	};

	// 用传协议相关
	let agrees = reactive({
		agreeList: [],
		agreeIndex: 0
	});
	// 获取用传协议列表数据
	let getAgreeList = async id => {
		loading.value.openLoading('加载中···'); // 打开loading
		const data = await proxy.$http
			.get({ url: `/teleporterProtocol/teleporterProtocol/protocolListByManufactorId/${id}` });
		loading.value.closeLoading(); // 关闭loading
		// console.log('用传协议---', data);
		if (data.code == 200) {
			agrees.agreeList = data.data;
			agrees.agreeIndex = 0;
			details.protocolId = agrees.agreeList[0].id;
			handleupdProtocol(); // 用传装置-----修改解析协议和主机厂家
		}
	};

	// 用传装置-----修改解析协议和主机厂家
	let handleupdProtocol = async () => {
		loading.value.openLoading('加载中···'); // 打开loading
		let dat = {
			id: details.id,
			protocolId: details.protocolId,
			manufactorId: details.manufactorId
		};
		const data = await proxy.$http.post({ url: `/install/updProtocol`, data: dat });
		loading.value.closeLoading(); // 关闭loading
		// console.log('用传装置-----修改解析协议和主机厂家---返回的数据', data);
	};

	// 点击切换协议
	let agreeClick = (item, index) => {
		uni.showModal({
			title: '请重新复位主机',
			content: '协议已切换，请重新复位主机',
			confirmColor: '#2954FD',
			showCancel: false,
			success: function (res) {
				if (res.confirm) {
					agrees.agreeIndex = index;
					details.protocolId = item.id;
					handleupdProtocol(); // 用传装置-----修改解析协议和主机厂家
				} else if (res.cancel) {}
			}
		});
	};

	// 获取终端的最新数据
	let lastData = reactive({ info: {} });
	let getLastData = async () => {
		loading.value.openLoading('加载中···'); // 打开loading
		const data = await proxy.$http.get({ url: `/install/lastData/${details.id}` });
		loading.value.closeLoading(); // 关闭loading
		// console.log('获取终端的最新数据---', data);
		if (data.code == 200) {
			if (JSON.stringify(data.data) != "{}") {
				lastData.info = data.data;
			} else {
				lastData.info = '';
			}
		}
	};


	// 调试终端系列操作
	let testDeviceParams = reactive({
		id: '',
		installImg: [], // 上传图片
		testResult: '', // 调试结果，1-成功，2-失败
		testFailReason: '' // 失败结果
	});

	// 上传安装图片
	let compressImgs = ref(null)
	let upateImgClick = () => {
		wx.chooseImage({
			count: 1,
			sizeType: ['compressed'], // original 原图，compressed 压缩图
			sourceType: ['camera', 'album'],
			success: function (res) {
				// console.log(res.tempFiles, '拍照---=-=-=-=-=-=')
				let item = res.tempFiles[0]
				loading.value.openLoading('上传中···'); // 打开loading
				imageCompress(item).then(resImgs => {
					// console.log(resImgs, '压缩返回------')
					let header = {
						Authorization: config.Authorization,
						'Blade-Auth': uni.getStorageSync('token'),
						'Tenant-Id': uni.getStorageSync('tenantId')
					};
					uni.uploadFile({
						url: config.baseUrl + '/blade-resource/oss/endpoint/put-file',
						filePath: resImgs.path,
						name: 'file',
						formData: { file: 'multipart/form-data' }, // , businessType: 'examineProblemPhoto'
						header: header,
						success: res => {
							loading.value.closeLoading(); // 关闭loading
							// console.log('上传照片返回的数据-------', JSON.parse(res.data).data.link);
							const data = JSON.parse(res.data);
							if (data.code == 200) {
								testDeviceParams.installImg.push(data.data.link);
							} else {
								uToast.value.openuToastError('上传失败，请重新上传'); // 打开loading
							}
						},
						fail() {
							loading.value.closeLoading(); // 关闭loading
							uToast.value.openuToastError('上传失败，请重新上传'); // 打开loading
						}
					});
				})
			}
		});
	};
	// 压缩图片
	let imageCompress = (file) => {
		return new Promise((resolve, reject) => {
			let { size, path } = file
			let type = Date.now()
			//大于1M进行压缩
			if ((size / 1024 / 1024) < 1) {
				resolve(file)
				return false
			}
			uni.compressImage({
				src: path,
				quality: 80,
				success: res => {
					// console.log('大于1M, 压缩后的数据----', res)
					let newPath = res.tempFilePath //  + type
					let newName = res.tempFilePath.split("/")[res.tempFilePath.split(
						"/").length - 1] + type
					uni.getFileInfo({
						filePath: res.tempFilePath,
						success: async (info) => {
							let newFile = {
								...file,
								size: info.size,
								path: newPath,
								name: newName,
								tempFilePath: res.tempFilePath
							}
							resolve(await imageCompress(newFile))
						}
					})
				}
			})
		})
	}
	// 删除图片
	let deteleImgClick = index => {
		uni.showModal({
			title: '删除图片',
			content: '是否删除当前图片？',
			showCancel: true,
			confirmColor: '#2954FD',
			success: function (res) {
				if (res.confirm) {
					testDeviceParams.installImg.splice(index, 1);
					uToast.value.openuToastSuccess('删除成功'); // 打开loading
				} else if (res.cancel) {}
			}
		});
	};
	// 预览图片
	let previewImgClick = (item, type) => {
		if (type == 1) {
			uni.previewImage({
				urls: details.installDetails.installImg,
				current: item
			});
		} else if (type == 2) {
			uni.previewImage({
				urls: details.installDetails.fireImg,
				current: item
			});
		} else if (type == 3) {
			uni.previewImage({
				urls: testDeviceParams.installImg,
				current: item
			});
		}
	};

	// 提交调试
	let installSubmit = async () => {
		let installImg = testDeviceParams.installImg.toString()
		let params = {
			id: details.id,
			installImg: installImg, // 上传图片
			testResult: testDeviceParams.testResult, // 调试结果，1-成功，2-失败
			testFailReason: testDeviceParams.testFailReason // 失败结果
		};
		if (!testDeviceParams.testResult) {
			uToast.value.openuToastError('请选择解析结果');
			return;
		}
		if (testDeviceParams.testResult == 2 && details.installDetails.isTeleporter == 1) {
			if (testDeviceParams.testFailReason == '') {
				uToast.value.openuToastError('请选择调试失败原因');
				return;
			}
		}
		loading.value.openLoading('提交中···'); // 打开loading
		const data = await proxy.$http.post({ url: '/install/testDevice', data: params });
		loading.value.closeLoading(); // 关闭loading
		// console.log('提交调试返回----结果', data);
		if (data.code == 200) {
			uToast.value.openuToastSuccess(data.msg);
			proxy.$pageJump.reLaunch('/pages/views/install/index');
		} else {
			uToast.value.openuToastError(data.msg);
		}
	};
</script>

<style scoped lang="scss">
	.installDetails {
		background: url('https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/loginBg.png') no-repeat;
		background-size: cover;
		position: fixed;
		top: 0;
		left: 0;
		height: 100vh;
		width: 100%;
		z-index: -1;
		padding: 26rpx 26rpx 60rpx;
		overflow-y: auto;

		.imgDevice {
			width: 100%;
			height: 155rpx;
		}

		.tips1 {
			padding: 8rpx;
			background-color: #eb5336;
			color: #fff;
			border-radius: 8rpx;
		}

		.tips2 {
			padding: 8rpx;
			background-color: #3865ff;
			color: #fff;
			border-radius: 8rpx;
		}

		.renovate {
			width: 52rpx;
			height: 30rpx;
		}

		.ident::before {
			content: '*';
			font-size: 30rpx;
			color: red;
			position: absolute;
			right: -15rpx;
			top: 0;
		}

		.agreeBox {
			&-title {
				width: 45%;
				margin-bottom: 20rpx;
			}
		}

		.agreeActive {
			font-weight: 600;
			color: #333;
		}

		.agreeInfo {
			height: 200rpx;
			margin-top: 10rpx;
			overflow-y: auto;
		}

		.tabsBut {
			width: 100%;
			padding: 60rpx 0;
		}

		.lastDataIcon {
			position: absolute;
			right: 1.5%;
			bottom: 6%;
		}
	}

	.imgsBox {
		&-img {
			width: 25%;
			padding: 1%;
		}
	}
</style>